<div ng-controller="Approval_PriceConfirmDatasC">
    <div class="bg-light lter b-b wrapper-md">
        <h1 class="m-n font-thin h3">审批详情</h1>
    </div>

    <div class="wrapper-md" style="text-align: center;">
        <div class="panel panel-default">
            <div class="panel-heading">

            </div>
            <div class="table-responsive">
                <table id="example1" class="table table-striped b-t b-light">
                    <thead>
                    <tr>
                        <th style="text-align: center;">名称</th>
                        <th style="text-align: center;">申请销售单价</th>
                        <th style="text-align: center;">当前销售单价</th>
                        <!--<th style="text-align: center;">允许最大负库存（t）</th>-->

                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="item in orderdetaildata">
                        <td style="width: 25%">{{item.CommodityName}}</td>
                        <td style="width: 15%">{{item.Price | number:2}}</td>
                        <td  style="width: 15%">{{item.OldPrice | number:2}}</td>
                        <!--<td style="width: 15%"><input ng-disabled="istrue" ng-model="item.MinAmount" type="number" min="0" class="form-control" required placeholder="请输入允许最大负库存"></td>-->

                        <!--<td style="width: 20%">-->
                        <!--<button class="btn btn-sm btn-default" ng-click="commedit()">-->
                        <!--<i class="fa fa-plus text"></i>-->
                        <!--<span class="text">编辑</span>-->
                        <!--</button>-->
                        <!--</td>-->
                    </tr>
                    </tbody>
                </table>
                <!--<div class="panel-heading" ng-include="'/htm/tpl/Provider/Paging.html'">-->
                <!--</div>-->
            </div>
        </div>
    </div>
    <div style="padding: 0px 15px">
        <span><b>流程类型：</b>{{data.TypeName}}</span><br>
        <span><b>内容：</b>{{data.Title}}</span><br>
        <span><b>申请人：</b>{{data.Creater.Name}}</span><br>
        <span><b>审批人：</b>{{data.NowApproverName}}</span><br>

        <label>审批意见</label>{{data.Remarks}}<br>
        <div ng-if="data.ApprovalState==1||data.ApprovalState==0">
            <input ng-disabled="item.ApprovalState==2||item.ApprovalState==3" ng-model="data.opinion" type="text" class="form-control">
            <button type="button" class="btn btn-success" ng-click="DoAppr(true)" ng-hide="item.ApprovalState==2||item.ApprovalState==3">通过</button>
            <button type="button" class="btn btn-warning" ng-click="DoAppr(false)" ng-hide="item.ApprovalState==2||item.ApprovalState==3">驳回</button>
            <button type="button" class="btn btn-default" ng-click="goorderList()">返回列表</button>
            <span ng-show="item.ApprovalState==2">已通过</span>
            <span ng-show="item.ApprovalState==3">已驳回</span>
        </div>
    </div>
    </div>

<script>
    angular.module('app') //非标优惠
            .controller("Approval_PriceConfirmDatasC", function($scope, $state, $http,$stateParams) {
                $http({
                    url: "/api/Approval?id=" + $stateParams.id,
                    method: "GET"
                    // data: { id: $stateParams.id}
                })
                        .then(function(res) {
                            $scope.data = res.data;
                            console.log($scope.data);
                            $http({
                                url: "../api/Provider/PriceConfirmDatas?batchId=" + $scope.data.Tag,
                                method: "GET"
                            })
                                    .then(function (res) {
                                        $scope.orderdetaildata = res.data;
                                        console.log($scope.orderdetaildata);
                                    })
                                    .then(function (error) {
                                        if (error) {
                                            console.log("error");
                                        }
                                    });
                        })
                        .then(function(error) {
                            if (error) {
                                alert("数据获取失败");
                            }
                        });

                //返回列表
                $scope.goorderList = function(){
                    $state.go('app.Approval_Index');
                };
                $scope.DoAppr= function(isOk) {
                    $http.post("/api/Approval/Approval?id=" + $stateParams.id + "&pass=" + isOk + "&opinion=" + $scope.data.opinion)
                            .success(function() {
                                alert("审批完成");
                                $scope.goorderList();
                            }).error(function() {alert("处理失败")})
                    ;
                }
            });

</script>